home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
bsrc_250.zip
/
B_SEARCH.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-15
|
13KB
|
367 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software, Co. */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / Freely Available<tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
/* */
/* */
/* This module was written by Vince Perriello */
/* */
/* */
/* BinkleyTerm Phone list Search Module */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.250. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT BIT BUCKET */
/* SOFTWARE CO. AT ONE OF THE ADDRESSES LISTED BELOW. IN NO EVENT */
/* SHOULD YOU PROCEED TO USE THIS FILE WITHOUT HAVING ACCEPTED THE */
/* TERMS OF THE BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER */
/* AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO. */
/* */
/* */
/* You can contact Bit Bucket Software Co. at any one of the following */
/* addresses: */
/* */
/* Bit Bucket Software Co. FidoNet 1:104/501, 1:343/491 */
/* P.O. Box 460398 AlterNet 7:491/0 */
/* Aurora, CO 80046 BBS-Net 86:2030/1 */
/* Internet f491.n343.z1.fidonet.org */
/* */
/* Please feel free to contact us at any time to share your comments about */
/* our software and/or licensing policies. */
/* */
/*--------------------------------------------------------------------------*/
/* Include this file before any other includes or defines! */
#include "includes.h"
int SaveScanList (int);
void wait_for_keypress(void);
int list_search ()
{
int saved_baud;
long t1;
int i, k, l;
int dirty;
ADDR ls_addr;
unsigned int kbd_input;
static unsigned int save_chars[] = {
SHF1, SHF2, SHF3, SHF4, SHF5,
SHF6, SHF7, SHF8, SHF9, SHF10
};
static unsigned int load_chars[] = {
ALTF1, ALTF2, ALTF3, ALTF4, ALTF5,
ALTF6, ALTF7, ALTF8, ALTF9, ALTF10
};
static unsigned int command_chars[] = {
PF1, PF2, PF3, PF4, PF5,
PF6, PF7, PF8, PF9, PF10
};
/*
* * Input the phone numbers we want to scan *
*
*/
dirty = 1;
/*
* Print out a null string nicely for OS/2
*/
#define NICE_TEXT(n) (((n) == NULL) ? "(none)" : n)
for (;;)
{
if (dirty)
{
screen_clear ();
(void) printf (MSG_TXT(M_PHONE_HELP));
(void) printf (MSG_TXT(M_PHONE_HELP2));
if (set_loaded)
(void) printf (MSG_TXT(M_LAST_SET),set_loaded);
(void) printf (MSG_TXT(M_CURRENT_PHONES));
for (k = 0; k < 10; k += 2)
{
(void) printf ("%2d: %35s %2d: %35s\n",
k + 1,
NICE_TEXT (scan_list[k]),
k + 2,
NICE_TEXT (scan_list[k + 1]));
}
(void) printf (MSG_TXT(M_INPUT_COMMAND));
dirty = 0;
}
while (!KEYPRESS ())
time_release ();
kbd_input = FOSSIL_CHAR ();
if (((kbd_input & 0xff) == '\n') || ((kbd_input & 0xff) == '\r'))
break;
if ((kbd_input & 0xff) == ESC)
return (0);
for (k = 0; k < 10; k++)
{
if (kbd_input == save_chars[k]) /* Save into a set? */
{
(void) SaveScanList(k); /* Yes, do it */
dirty = 1; /* Force redisplay */
k = 10; /* Then fool the logic*/
break;
}
if (kbd_input == load_chars[k]) /* Load from a set? */
{
(void) LoadScanList(k,1); /* Yes, do it */
dirty = 1; /* Force redisplay */
k = 10; /* Then fool the logic*/
break;
}
if (kbd_input == command_chars[k]) /* Plain old Fkey? */
break; /* Yup, get out now */
}
if (k == 10) /* Not a function key */
{
k = (kbd_input & 0xff) - '0'; /* Convert from digit */
if ((k < 0) || (k > 9)) /* Was it a digit? */
continue; /* No, throw char out */
if (!k) /* Is it a zero? */
k = 9; /* That's 9 to us */
else --k; /* Else make zero-rel */
}
(void) printf (MSG_TXT(M_ELEMENT_CHOSEN), k + 1);
if (scan_list[k] != NULL)
{
(void) printf (MSG_TXT(M_CURRENTLY_CONTAINS), scan_list[k]);
(void) printf (MSG_TXT(M_PHONE_HELP3));
}
else
{
(void) printf (MSG_TXT(M_PHONE_HELP4));
}
(void) gets (junk); /* Get the user's input */
++dirty; /* Always redisplay */
if ((l = (int) strlen (junk)) == 0) /* If nothing there, */
continue; /* move along */
if (l == 1 && *junk == ' ') /* If just a space... */
{
if (scan_list[k] != NULL) /* Delete old number */
free(scan_list[k]);
scan_list[k] = NULL; /* Clean up the ref */
continue; /* End this iteration */
}
if (scan_list[k] != NULL) { /* Get rid of old num */
free(scan_list[k]);
}
if ((scan_list[k] = calloc( 1, (unsigned int) (++l))) == NULL) /* Allocate space */
{
(void) printf (MSG_TXT(M_MEM_ERROR));
return (0); /* Get out for error */
}
(void) strcpy